package org.example.service.impl;

import jakarta.annotation.Resource;
import org.example.mapper.FamilyMapper;
import org.example.service.FamilyService;
import org.example.utils.FamilyUpdateRequest;
import org.example.utils.R;
import org.springframework.stereotype.Service;

/**
 * ClassName: FamilyServiceImpl
 * Description:
 *
 * @Author Kotaro
 * @Create 2024/12/2 11:09
 * @Version 1.0
 */
@Service
public class FamilyServiceImpl implements FamilyService {
    @Resource
    private FamilyMapper familyMapper;

    @Override
    public boolean isElderlyBoundToFamily(String familyId, String elderlyId) {
        return familyMapper.isElderlyBoundToFamily(familyId , elderlyId);
    }

    @Override
    public R updateFamilyByFamilyId(FamilyUpdateRequest familyUpdateRequest) {
        int rows = familyMapper.updateFamilyByFamilyId(familyUpdateRequest);
        if(rows> 0){
            return R.successful("修改成功" , familyUpdateRequest);
        }else {
            return R.error("修改失败" , null);
        }
    }
}
